$(function () {
    var input = document.getElementById("file_input");
    // alert(input);
    input.addEventListener('change', readFile, false);
    function readFile() {
        var file = this.files[0]; //获取file对象
        var formData = new FormData($("#uploadForm")[0])  //创建一个forData 
        formData.append('file', file) //把file添加进去  name命名为img
        $.ajax({
            url: "/upload_dp",
            data: formData,
            type: "POST",
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            success: function (data) {
                // alert(data.url);
                //成功
                alert("上传成功！");
                window.open("http://localhost:8080/myself");
            },
            error: function () {
                //失败
            }
        })
    }

    //
    //

});
